﻿#ifndef TCPLISTENER_H
#define TCPLISTENER_H

#include <qtcpserver.h>
#include <qtimer.h>
#include <qtcpsocket.h>

#include "ObjAutoInject.h"
#include "LogSaver.h"

class TcpIOer;
class TcpListener :  public QTcpServer,public ObjAutoInject
{
  Q_OBJECT
private:
  enum PrivateSignalClass
  {
    PrivateSignal
  };
private://property
private://dependency
  LogSaver* logSaver=LogSaver::getLogSaver();
public:
  explicit TcpListener();
  virtual ~TcpListener();
signals:
  void signal_newConnection(TcpIOer* newTCPSocket);//发送新的TCPsocket和它的超时计时器，在接到该信号第一时间应停止计时器
  void signal_setSocketDescriptor(qintptr socketDescriptor,
                                  QTcpSocket::SocketState state = QTcpSocket::ConnectedState,
                                  QTcpSocket::OpenMode openMode = QTcpSocket::ReadWrite,
                                  TcpListener::PrivateSignalClass privateSignalClass=TcpListener::PrivateSignal);
protected:
  virtual void incomingConnection(qintptr socketDescriptor)override;
};

#endif // TCPLISTENER_H
